<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      ul {
        display: flex;
      }
      li {
        list-style-type: none;
        margin-right: 30px;
      }
      .active {
        background-color: pink;
        width: 100px;
        height: auto;
      }
      a{
        text-decoration: none;
      }
    </style>
  </head>
  <body>
    <div id="app">
      {{msg}}
      <ul>
        <li v-for="(item,index) in arr" :key="item.id" @click="active(index)">
          <a href="#" :class="{active: activeIndex === index}">{{item.name}}</a>
        </li>
      </ul>
    </div>
  </body>

  <script src="js/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      data: {
        msg: "hello world",
        activeIndex: 0,
        arr: [
          { id: 1, name: "京东秒杀" },
          { id: 2, name: "京东超市" },
        ],
      },
      methods: {
        active(index){
          this.activeIndex = index;
        }
      },
    });
  </script>
</html>
